﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ProjScan.RecordManager;
using ProjScan.RecordManager.AssetData;
using ProjScan.Submodules.Scene_Check;
using ProjScan.Tools;

namespace ProjScan.ScanRule.SceneCheck
{
	// Token: 0x020001A8 RID: 424
	internal class SceneObjRecordRuleImp : RecordRuleImp<SceneObjAssetData, SceneObjRecordManager>
	{
		// Token: 0x17000350 RID: 848
		// (get) Token: 0x06000E54 RID: 3668 RVA: 0x0000719A File Offset: 0x0000539A
		public override bool HasWhiteList
		{
			get
			{
				return false;
			}
		}

		// Token: 0x06000E55 RID: 3669 RVA: 0x0000719D File Offset: 0x0000539D
		public SceneObjRecordRuleImp()
		{
			this.hasSeparateTargetDirSettings = false;
		}

		// Token: 0x17000351 RID: 849
		// (get) Token: 0x06000E56 RID: 3670 RVA: 0x00041468 File Offset: 0x0003F668
		public override string DetailOutputPath
		{
			get
			{
				string str = "ErrorScene";
				bool flag = this.SceneId != null;
				if (flag)
				{
					str = Path.GetFileNameWithoutExtension(ScenesMapData.Instance.GetScenePathByIndex(base.SceneId.Value));
				}
				return Path.Combine(ToolsHelper.GetFailDetailPath(), this.RuleKey + "-" + str + ".csv");
			}
		}

		// Token: 0x06000E57 RID: 3671 RVA: 0x000417AC File Offset: 0x0003F9AC
		public override void FixRule()
		{
			bool flag = this.failAssetInfos != null && this.failAssetInfos.Count != 0;
			if (flag)
			{
				Dictionary<string, FailedAssetInfo> dictionary = new Dictionary<string, FailedAssetInfo>();
				int num = 0;
				foreach (KeyValuePair<string, FailedAssetInfo> keyValuePair in this.failAssetInfos)
				{
					List<string> list = new List<string>();
					char[] separator = new char[]
					{
						'$'
					};
					list = Enumerable.ToList<string>(keyValuePair.Key.Split(separator));
					string text = list[0];
					string text2 = list[1];
					ToolsHelper.ShowProgressBar("Fixing....", "From scene: (" + text + "). Fixing Resource: " + text2, (float)num * 1f / (float)num, false);
					bool flag2 = Path.GetFullPath(text) == Path.GetFullPath(this.SceneName) && keyValuePair.Value.ShouldBeFixed && !keyValuePair.Value.IsFixed;
					if (flag2)
					{
						FailedAssetInfo failedAssetInfo = new FailedAssetInfo();
						bool flag3 = this.InvokeFixer(text2);
						if (flag3)
						{
							FixLog.Instance.Log(this.fixerType, this.SceneName + "$hierachy");
							failedAssetInfo.IsFixed = true;
							failedAssetInfo.ShouldBeFixed = false;
						}
						else
						{
							failedAssetInfo.IsFixed = keyValuePair.Value.IsFixed;
							failedAssetInfo.ShouldBeFixed = keyValuePair.Value.ShouldBeFixed;
						}
						failedAssetInfo.ShouldJoinWhiteList = keyValuePair.Value.ShouldJoinWhiteList;
						dictionary.Add(keyValuePair.Key, failedAssetInfo);
					}
					else
					{
						dictionary.Add(keyValuePair.Key, keyValuePair.Value);
					}
					num++;
				}
				this.failAssetInfos = dictionary;
			}
		}
	}
}
